package com.td.core.pathfinding;

import com.td.core.obj.TDMap;

public class RiskAStar extends AStar{
	
	int range = 8;
	int maxRiskCost = 1000;
	
	
	protected int[][] updateRisk(int[][] map) {
		
		for(int i = 0 ; i < TDMap.MAP_X ; i++)
			for(int j = 0 ; j < TDMap.MAP_Y ; j++)
				if(map[i][j] == OBSTACLE) {
					for(int k = i - range ; k <= i + range ; k++)
						for(int l = j - range ; l <= j + range ; l++)
							if(k >= 0 && k < map.length && l >= 0 && l < map[i].length)
								if(map[k][l] != OBSTACLE) {
									
									int dis = Math.abs(k - i) + Math.abs(l - j);
									
									map[k][l] += maxRiskCost / dis;
								}
				}
		
		return map;
		
	}
}
